﻿
using System.Web;

namespace Tau.Web.Infrastructure
{
    internal static class Session
    {
        public static void SetSortBy(string sortBy)
        {
            if (sortBy == SortBy)
            {
                SortDescending = !SortDescending;
            }
            else
            {
                SortDescending = false;
            }
            SortBy = sortBy;
        }

        public static bool SortDescending
        {
            get
            {
                if (HttpContext.Current.Session["SortDescending"] == null)
                {
                    HttpContext.Current.Session["SortDescending"] = false;
                }
                return (bool)HttpContext.Current.Session["SortDescending"];
            }
            set
            {
                HttpContext.Current.Session["SortDescending"] = value;
            }
        }
        public static string SortBy
        {
            get
            {
                if (HttpContext.Current.Session["SortBy"] == null)
                {
                    HttpContext.Current.Session["SortBy"] = string.Empty;
                }
                return (string)HttpContext.Current.Session["SortBy"];
            }
            set
            {
                HttpContext.Current.Session["SortBy"] = value;
            }
        }
    }
}